<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>  数据列表</span>
        <el-button style="float: right; padding: 3px 0" type="text" @click="add">添加</el-button>
      </div>
    </el-card>

    <el-table ref="multipleTable" :data="productAttribute" tooltip-effect="dark" style="width: 200%">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>
      <el-table-column label="编号" width="150">
        <template slot-scope="scope">{{ scope.row.id }}</template>
      </el-table-column>
      <el-table-column label="属性名称" width="150">
        <template slot-scope="scope">{{ scope.row.name }}</template>
      </el-table-column>
      <el-table-column label="商品类型" width="150">
        <template slot-scope="scope">{{ scope.row.categoryName }}</template>
      </el-table-column>
      <el-table-column label="属性是否可选" width="150">
        <template slot-scope="scope" v-show="scope.row.selectType ===0">唯一</template>
        <template slot-scope="scope" v-show="scope.row.selectType ===1">单选</template>
        <template slot-scope="scope" v-show="scope.row.selectType ===2">多选</template>
      </el-table-column>
      <el-table-column label="属性值的录入方式" width="150">
        <template slot-scope="scope" v-show="scope.row.inputType===0">手工录入</template>
        <template slot-scope="scope" v-show="scope.row.inputType===1">从列表中选取</template>
      </el-table-column>
      <el-table-column label="可选列表" width="150">
        <template slot-scope="scope">{{ scope.row.inputList }}</template>
      </el-table-column>
      <el-table-column label="排序" width="150">
        <template slot-scope="scope">{{ scope.row.sort }}</template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="mini"
              @click="handleEdit1(scope.row)">编辑</el-button>
          <el-button
              size="mini"
              type="danger"
              @click="handleDelete1(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-select>
      <el-option value="批量操作">批量操作</el-option>
      <el-option value="删除">删除</el-option>
    </el-select>
    <el-button style="background-color: #00afff">确定</el-button>
    <el-pagination
        @size-change="handleSizeChange1"
        @current-change="handleCurrentChange1"
        style="float: right; padding: 3px 0" type="text"
        :current-page=pageNum1
        :page-sizes="[1  , 10  , 15]"
        :page-size=pageSize1
        layout="total, sizes, prev, pager, next, jumper"
        :total=total1>
    </el-pagination>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）,
//例如：import 《组件名称》 from '《组件路径》,
  import {findProductAttribute} from "@/api/product/productAttribute";

export default {
    //import引入的组件需要注入到对象中才能使用"
    components: {},
    props: {},
    data() {
      //这里存放数据"

      return {
        productAttribute:{},
        pageNum1:1,
        pageSize1:3,
        id:'',
        total1:''
      };
    },
    //计算属性 类似于data概念",
    computed: {},
    //监控data中的数据变化",
    watch: {},
    //方法集合",
    methods: {
      handleEdit1(val){
        this.$router.push({path:'/product/updateproductAttribute',query:{productAttributeDTO:val}})
      },
      add(){
          this.$router.push({path:'/product/addproductAttribute',query:{type:0}})
      },
      findList(){
        findProductAttribute(this.id,this.pageNum1,this.pageSize1).then(
            res=>{
              this.productAttribute=res.data.rows
              this.total1=res.data.total
            }
        )
      },
      handleSizeChange1(val) {
        this.pageSize1=val
        this.findList(this.id)
      },
      handleCurrentChange1(val) {
        this.pageNum1=val
        this.findList(this.id)
      },
    },
    //生命周期 - 创建完成（可以访问当前this实例）",
    created() {
      this.id=this.$route.query.id
      this.findList()
    },
    //生命周期 - 挂载完成（可以访问DOM元素）",
    mounted() {
    },
    beforeCreate() {
    }, //生命周期 - 创建之前",
    beforeMount() {
    }, //生命周期 - 挂载之前",
    beforeUpdate() {
    }, //生命周期 - 更新之前",
    updated() {
    }, //生命周期 - 更新之后",
    beforeDestroy() {
    }, //生命周期 - 销毁之前",
    destroyed() {
    }, //生命周期 - 销毁完成",
    activated() {
    } //如果页面有keep-alive缓存功能，这个函数会触发",
  };
</script>
<style scoped>

</style>
